package com.wgchao.authodemo.application.mapstruct.mapper.vtod;

import com.wgchao.authodemo.application.mapstruct.dto.AgencyDTO;
import com.wgchao.authodemo.userInterface.vo.agency.AgencyVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @作者  wgchao
 * @时间 2019-12-10 
 * @用途  
 */
@Component
public class AgencyVDMapper implements CommonVDMapper<AgencyVO, AgencyDTO> {


    @Override
    public AgencyDTO toDTO(AgencyVO agencyVO) {
        AgencyDTO agencyDTO = new AgencyDTO();
        BeanUtils.copyProperties(agencyVO, agencyDTO);
        return agencyDTO;
    }

    @Override
    public AgencyVO toVO(AgencyDTO agencyDTO) {
        AgencyVO agencyVO = new AgencyVO();
        BeanUtils.copyProperties(agencyDTO, agencyVO);
        if(agencyDTO.getParAgency() != null){
            agencyVO.setParAgencyName(agencyDTO.getParAgency().getAgencyName());
        }
        return agencyVO;
    }
}
